package methods;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Scanner;


import com.rsbuddy.script.ActiveScript;

public class currentPlayer extends ActiveScript{
	public static int nextChar;
	public static int line, charNumber, vps;
	public static String acc, pass, name, leaderName;
	public static int leader = 0;
	public static int buyed;
	
	public static void selectPlayer() throws IOException{
		try  
	    {    
			
			if(nextChar < 1){
				nextChar = 3;
			}
			 Scanner lineScanner;  
			 BufferedReader bufferedFileReader = new BufferedReader(new FileReader("Storage/TantricBots/feathers.txt"));  
			 String currentLine = bufferedFileReader.readLine();  
			 while(currentLine != null)  
			 {  
		        lineScanner = new Scanner(currentLine);  
		        lineScanner.useDelimiter(",");  
		        line = lineScanner.nextInt(); 
		        acc = lineScanner.next();  
		        pass = lineScanner.next();  
		        name = lineScanner.next(); 
		        vps = lineScanner.nextInt(); 
		        charNumber = lineScanner.nextInt(); 
		        
		        if(line == 0){
		        	leaderName = name;
		        	if(leader == 1){
	        			line = nextChar;
	        			return;
		        	}
		        }
		        currentLine = bufferedFileReader.readLine();  
				if(charNumber == nextChar){
						nextChar++;
						return;
				}		        	
			}
	    }
		catch(Exception e){
			File dir = new File("Storage/TantricBots");
			File f = new File ("Storage/TantricBots/feathers.txt");
			if(!dir.exists()){
				dir.mkdir();
			}
			if(!f.exists()){
				f.createNewFile();
			}
		}
	}

	@Override
	public int loop() {
		// TODO Auto-generated method stub
		return 0;
	}
}
